package com.example.administrator.nl.adapter;

import android.os.Build;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.administrator.nl.R;
import com.example.administrator.nl.bean.AppointmentProjectBean;

import java.util.List;

/**
 * Created by yuanmengkai on 2019/8/21.
 */

public class AppointmentProjectAdapter extends BaseQuickAdapter<AppointmentProjectBean, BaseViewHolder> {

    public AppointmentProjectAdapter(@LayoutRes int layoutResId, @Nullable List<AppointmentProjectBean> data) {
        super(layoutResId, data);
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Override
    protected void convert(BaseViewHolder helper, AppointmentProjectBean item) {
        LinearLayout ll_line_appointment = helper.getView(R.id.ll_line_appointment);
        TextView tv_time_appointment = helper.getView(R.id.tv_time_appointment);
        TextView tv_appointment = helper.getView(R.id.tv_appointment);
        helper.addOnClickListener(R.id.ll_line_appointment);
        // 不可预约
        if (item.getMake().equals("0")) {
            tv_time_appointment.setText(item.getMakeTime());
            tv_appointment.setText("不可预约");
            ll_line_appointment.setBackground(helper.itemView.getResources().getDrawable(R.drawable.frame_bfbfbf_5));;
            tv_time_appointment.setTextColor(helper.itemView.getResources().getColor(R.color.gray_bfbfbf));
            tv_appointment.setTextColor(helper.itemView.getResources().getColor(R.color.gray_bfbfbf));


        } else if (item.getMake().equals("1")) {
            // 可以预约
            tv_appointment.setText("预约");
            tv_time_appointment.setText(item.getMakeTime());
            ll_line_appointment.setBackground(helper.itemView.getResources().getDrawable(R.drawable.frame_333333_5));;
            tv_time_appointment.setTextColor(helper.itemView.getResources().getColor(R.color.black_333333));
            tv_appointment.setTextColor(helper.itemView.getResources().getColor(R.color.black_333333));
        }else if(item.getMake().equals("2")){
            // 可以预约
            tv_appointment.setText("预约");
            tv_time_appointment.setText(item.getMakeTime());
            ll_line_appointment.setBackground(helper.itemView.getResources().getDrawable(R.drawable.frame_60d1f7_5));;
            tv_time_appointment.setTextColor(helper.itemView.getResources().getColor(R.color.color_white_ffffff));
            tv_appointment.setTextColor(helper.itemView.getResources().getColor(R.color.color_white_ffffff));
        }
    }
}
